<?php
class MHDEV_View_Helper_SendMessage extends Zend_View_Helper_Abstract
{
	/*
	 * Send a PM to a user
	 * 
	 * @param int receiver
	 * @param string title
	 * @param string text
	 * @param int user_uid (optional)
	 * 
	 * @return int insert_uid for this message
	 */
	public function SendMessage($receiver, $title, $text, $user_uid = FALSE)
	{
		// db
		$messages = new Messages();
		
		if($user_uid)
		{
			$uid = $user_uid;
		}
		else
		{
			$uid = 0;
		}
		
		// insert message
		return $messages->insert(array(
			'user_uid'		=> $uid,
			'receiver_uid'	=> $receiver,
			'create_date'	=> new Zend_Db_Expr('NOW()'),
			'title'			=> $title,
			'text'			=> $text,
			'is_notice'		=> 1
		));
	}
}
?>